// pages/hospital/hospital.js
var party_notices_list = require('../../data/notice/hospital.js').notices_list
Page({

  data: {
    current: 'tab2',
    index: 1,
    tabs: [
      {
          key: 'tab1',
          title: '我的预约',
          content: 'Content of tab 1',
      },
      {
          key: 'tab2',
          title: '医师预约',
          content: 'Content of tab 2',
      }
    ],
  },

  onLoad: function (options) {
    var that = this
    var banner_notices = []
    for(var i=0; i<party_notices_list.length; i++){
      if(party_notices_list[i].top_status==true){
        banner_notices.push(party_notices_list[i])
      }
    }
    this.setData({
      party_notices: party_notices_list,
      banner_notices: banner_notices
    })

    wx.getSystemInfo({ 
      success: function (res) { 
          that.setData({ 
              clientHeight: res.windowHeight-200 
          }); 
      }
  })
  },
  onNoticeTap: function (e){
    var notice_id = e.currentTarget.dataset.notice_id
    wx.navigateTo({
      url: '../notice/single_notice/single_notice?id=' + notice_id,
    })
  },
  onTabsChange(e) {
    // console.log('onTabsChange', e)
    const { key } = e.detail
    const index = this.data.tabs.map((n) => n.key).indexOf(key)

    this.setData({
        key,
        index,
    })
  },
  onSwiperChange(e) {
    // console.log('onSwiperChange', e)
    const { current: index, source } = e.detail
    const { key } = this.data.tabs[index]

    if (!!source) {
        this.setData({
            key,
            index,
        })
    }
  },
})